<!--如果想要新增一个新的模块 可以直接拿着个-->
<template>
  <div>
    <!--头部-->
    <!-- 查询框的组件  -->
    <div class="select">
      专业名称
      <el-input type="text" style="width: 320px;" v-model="zymc"></el-input>
      <!--      根据学科层次查询-->
      <!--      <el-input type="text" style="width: 120px" v-model="xlcc"></el-input>-->
      <!--      根据专业代码查询-->
      <!--      <el-input type="text" style="width: 120px" v-model="zydm"></el-input>-->
    </div>
    <!--查询的组件-->
    <div class="box3">
      学历层次
      <el-radio-group v-model="radio">
        <el-radio :label="3">本科(普通教育)</el-radio>
        <el-radio :label="6">本科(职业教育)</el-radio>
        <el-radio :label="9" size="20px">高职(专科)</el-radio>
      </el-radio-group>
    </div>

    <div class="box4">
      门类&nbsp;
      <el-select style="margin-right: 60px" v-model="value1" multiple placeholder="请选择">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>

    </div>

    <div class="box5">
      专业类&nbsp;
      <el-select v-model="value1" multiple placeholder="请选择">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
      <el-button type="primary" icon="el-icon-search">查询</el-button>
    </div>


    <!--    <div class="box1">-->
    <!--      根据门类查询-->
    <!--      <el-input type="text" style="width: 120px" v-model=ml></el-input>-->
    <!--      根据学科查询-->
    <!--      <el-input type="text" style="width: 120px" v-model="xk"></el-input>-->
    <!--      根据专业介绍查询-->
    <!--      <el-input type="text" style="width: 120px" v-model="zyjs"></el-input>-->
    <!--      <el-button type="primary" icon="el-icon-search" @click="searchAny">搜索</el-button>-->
    <!--    </div>-->


    <!--    &lt;!&ndash;数据的显示&ndash;&gt;-->
    <!--    <div class="box2">-->
    <!--      <el-select v-model="value" placeholder="请选择">-->
    <!--        <el-option-->
    <!--          v-for="item in options"-->
    <!--          :key="item.value"-->
    <!--          :label="item.label"-->
    <!--          :value="item.value">-->
    <!--        </el-option>-->
    <!--      </el-select>-->
    <!--    </div>-->

    <!--数据的绑定处理-->
    <div class="box6">
      <!-- 这里进行了我们的数据绑定   -->
      <el-table
        :data="tableData"
        border
        style="width: 100%">
        <el-table-column
          id="cc"
          prop="id"
          label="专业id"
          width="200" style="text-align: center">
        </el-table-column>
        <el-table-column

          prop="zymc"
          label="专业名称"
          width="200">
        </el-table-column>
        <el-table-column
          prop="xlcc"
          label="学历层次"
          width="200">
        </el-table-column>
        <el-table-column
          prop="zydm"
          label="专业代码"
          width="200">
        </el-table-column>
        <el-table-column
          prop="ml"
          label="门类"
          width="200">
        </el-table-column>
        <el-table-column
          prop="xk"
          label="学科"
          width="200">
        </el-table-column>

        <el-table-column
          label="操作"
          width="220">
          <template scope="scope">
            <el-popover
              placement="right"
              width="400"
              trigger="click">
              <span>{{scope.row.zyjs}}</span>
              <el-button slot="reference">点击查看专业信息</el-button>
            </el-popover>

          </template>
        </el-table-column>

        <el-table-column
          label="修改&新增"
          style="text-align: center"
          width="200">
          <!-- 这个是我们的修改和新增的弹出框的实现-->


          <!--          -->
          <template scope="scope">
            <el-popover
              placement="right"
              width="400"
              trigger="click">
              <h4> 专业代码</h4>
              <el-input v-model="gk.zydm" placeholder="请输入内容"></el-input>
              <h4> 门类 </h4>
              <el-input v-model="gk.ml" placeholder="请输入内容"></el-input>
              <h4>学科 </h4>
              <el-input v-model="gk.xk" placeholder="请输入内容"></el-input>
              <h4> 学历层次 </h4>
              <el-input v-model="gk.xlcc" placeholder="请输入内容"></el-input>
              <h4> 专业名称 </h4>
              <el-input v-model="gk.zymc" placeholder="请输入内容"></el-input>
              <h4> 专业介绍 </h4>
              <textarea class="textarea" v-model="gk.zyjs"
              ></textarea>
              <el-button type="danger" style="float: right;margin: 10px" @click="clear">重置</el-button>
              <el-button type="primary" style="float: right;margin: 10px;" @click="update">提交</el-button>
              <!-- 将我们的id进行传递 然后进行数据的回显 -->
              <el-button slot="reference" @click="toUpdate(scope.row.id)">修改</el-button>
            </el-popover>
          </template>
        </el-table-column>

      </el-table>
    </div>

    <!--  底部页面的跳转-->
    <div class="block">
      <el-button-group>
        <el-button type="primary" icon="el-icon-arrow-left" @click="before">上一页</el-button>
        <el-input type="text" style="width: 80px" @keyup.enter="searchByPage1"
                  v-model="page"></el-input>
        <el-button type="primary" @click="next">下一页<i class="el-icon-arrow-right el-icon--right"></i>
        </el-button>
        <el-button type="primary" icon="el-icon-search" @click="searchByPage(this.page)"
        >搜索
        </el-button>
      </el-button-group>
    </div>
  </div>
</template>
<script>
  export default {
    name: "index",
    //数据显示
    data() {
      return {
        radio: 3,
        zydm: "",
        xl: "",
        xlcc: "",
        ml: "",
        xk: "",
        zyjs: "",
        zymc: "",
        tableData: [],
        dialogVisible: false,
        page: 1,
        gk: {zydm: "", zymc: "", xlcc: "", ml: "", xk: "", zyjs: ""},//这个是我们进行更新的数据
      }

    },
    methods: {

      //方法
      //实际的更新
      update() {
        let _this = this;
        this.$axios.post('http://localhost:80/xgk/save', this.gk).then(rep => {
          location.reload();
        })
      },
      //去更新（将我们的数据进行回显）

      toUpdate(id) {
        let _this = this;
        this.$axios.get('http://localhost:80/xgk/selectById', {
          params: {
            id: id
          }
        }).then(rep => {
          _this.gk = rep.data//这里进行 我们的数据的回显进行
        })

      },

      //重置我们的输入框
      clear() {
        this.gk = {};
      },

      //进行我们的searchany
      searchAny() {
        let _this = this;
        this.$axios.get('http://localhost:80/xgk/selectByAny', {
          params: {
            zymc: this.zymc,
            xlcc: this.xlcc,
            zydm: this.zydm,
            ml: this.ml,
            xk: this.xk,
            zyjs: this.zyjs,
            current: 1,
            limit: 20
          }
        }).then(rep => {
          console.log(_this.zymc)
          _this.tableData = rep.data

        })

      },

      //根据页面进行查询
      searchByPage1() {

        let _this = this;
        this.$axios.get('http://localhost:80/xgk/selectByAny', {
          params: {
            zymc: this.zymc,
            xlcc: this.xlcc,
            zydm: this.zydm,
            ml: this.ml,
            xk: this.xk,
            zyjs: this.zyjs,
            current: this.page,
            limit: 20
          }
        }).then(rep => {
          console.log(_this.zymc)
          _this.tableData = rep.data

        })

      },
      searchByPage() {

        let _this = this;
        this.$axios.get('http://localhost:80/xgk/selectByAny', {
          params: {
            zymc: this.zymc,
            xlcc: this.xlcc,
            zydm: this.zydm,
            ml: this.ml,
            xk: this.xk,
            zyjs: this.zyjs,
            current: this.page,
            limit: 20
          }
        }).then(rep => {
          console.log(_this.zymc)
          _this.tableData = rep.data

        })

      },
      //去到下一页
      next() {
        this.page++;
        let _this = this;
        this.$axios.get('http://localhost:80/xgk/selectByAny', {
          params: {
            zymc: this.zymc,
            xlcc: this.xlcc,
            zydm: this.zydm,
            ml: this.ml,
            xk: this.xk,
            zyjs: this.zyjs,
            current: this.page,
            limit: 20
          }
        }).then(rep => {
          console.log(_this.zymc)
          _this.tableData = rep.data

        })

      },

      //去到前一页
      before() {
        if (this.page < 1) {
          alert('越界了')
          this.page = 1;
        }
        this.page--;
        let _this = this;
        this.$axios.get('http://localhost:80/xgk/selectByAny', {
          params: {
            zymc: this.zymc,
            xlcc: this.xlcc,
            zydm: this.zydm,
            ml: this.ml,
            xk: this.xk,
            zyjs: this.zyjs,
            current: this.page,
            limit: 20
          }
        }).then(rep => {
          console.log(_this.zymc)
          _this.tableData = rep.data

        })
      }
    },
    //初始化（调用声明周期的钩子）
    created() {
      let _this = this;
      this.$axios.get('http://localhost:80/xgk/selectByPage', {
        params: {
          page: this.page,
          limit: 20
        }
      }).then(function (rep) {
        _this.tableData = rep.data
      })
    }
  }
</script>
<style scoped>
  .select {
    margin-top: 30px;
    margin-right: 1600px;
  }

  .textarea {
    vertical-align: top;
    outline: none;
    height: 280px;
    width: 400px;
    font-family: "微软雅黑";
    color: #6c6c6c;

  }

  /*.box1 {*/
  /*  margin-right: 590px;*/
  /*}*/

  /*.box2 {*/
  /*  margin-right: 1000px;*/
  /*}*/

  .box3 {

    margin-top: 30px;
    margin-right: 1440px;

  }

  .box4 {
    margin-top: 30px;
    margin-right: 1570px;
  }

  .box5 {
    margin-top: -42px;
    margin-right: 800px;
  }

  .box6 {
    margin-top: 40px;
  }

</style>

